﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public static class Extension
    {
        /// <summary>
        /// 扩展字符串转数字
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static int ToInt32(this string? value)
        {
            if (value==null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(value);
            }
        }
        /// <summary>
        /// 根据身份证计算出生年月日
        /// </summary>
        /// <param name="cardId"></param>
        /// <returns></returns>
        public static string GetBirthByCarId(this string cardId)
        {
            string res = cardId.Substring(6, 8);
            return res;
        }
        /// <summary>
        /// 日期转为年月日
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetDateTime(this DateTime date)
        {
            string time = date.ToString("yyyy年MM月dd日");
            return time;
        }

    }
}
